GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Select.selectDropdown   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
/**
2
 * This file is part of the O2System Venus UI Framework package.
3
 *
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 *
7
 * @author         Steeve Andrian Salim
8
 * @copyright      Copyright (c) Steeve Andrian Salim
9
 */
10
// ------------------------------------------------------------------------
11
12
import * as $ from 'jquery';
13
import 'select2';
14
import 'bootstrap-select';
15
import 'selectize';
16
require('multiselect');
17
require('jquery.quicksearch');
18
19
/**
20
 * Class Select
21
 *
22
 * @author          Teguh Rianto
23
 * @package         Components
24
 */
25
export default class Select {
26
    constructor() {
27
        /**
28
         * Initiate select with search
29
         */
30
        this.selectWithSearch();
31
32
        /**
33
         * Initiate select insertable search
34
         */
35
        this.selectInsertableSearch();
36
37
        /**
38
         * Initiate select dropdown
39
         */
40
        this.selectDropdown();
41
42
        /**
43
         * Initiate select multi
44
         */
45
        this.selectMulti();
46
    }
47
48
    selectWithSearch() {
49
        $(".select-with-search").select2();
50
    }
51
52
    selectInsertableSearch() {
53
        $('.select-insertable-search').selectize({
54
            create: true,
55
            sortField: 'text'
56
        });
57
58
        $('.select-with-tags').selectize({
59
            delimiter: ',',
60
            persist: false,
61
            create: function (input) {
62
                return {
63
                    value: input,
64
                    text: input
65
                }
66
            }
67
        });
68
    }
69
70
    selectDropdown() {
71
        $('.select-dropdown').selectpicker();
72
    }
73
74
    selectMulti() {
75
        $('.multiselect-search').multiSelect({
76
            selectableHeader: "<input type='text' class='search-input form-control mb-2' autocomplete='off' placeholder='Search...'>",
77
            selectionHeader: "<input type='text' class='search-input form-control mb-2' autocomplete='off' placeholder='Search...'>",
78
            afterInit: function(ms){
0 ignored issues
show
Unused Code introduced by
The parameter ms is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
79
              var that = this,
80
                  $selectableSearch = that.$selectableUl.prev(),
81
                  $selectionSearch = that.$selectionUl.prev(),
82
                  selectableSearchString = '#'+that.$container.attr('id')+' .ms-elem-selectable:not(.ms-selected)',
83
                  selectionSearchString = '#'+that.$container.attr('id')+' .ms-elem-selection.ms-selected';
84
          
85
              that.qs1 = $selectableSearch.quicksearch(selectableSearchString)
86
              .on('keydown', function(e){
87
                if (e.which === 40){
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if e.which === 40 is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
88
                  that.$selectableUl.focus();
89
                  return false;
90
                }
91
              });
92
          
93
              that.qs2 = $selectionSearch.quicksearch(selectionSearchString)
94
              .on('keydown', function(e){
95
                if (e.which == 40){
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if e.which == 40 is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
96
                  that.$selectionUl.focus();
97
                  return false;
98
                }
99
              });
100
            },
101
            afterSelect: function(){
102
              this.qs1.cache();
103
              this.qs2.cache();
104
            },
105
            afterDeselect: function(){
106
              this.qs1.cache();
107
              this.qs2.cache();
108
            }
109
        
110
        });
111
    }
112
}